home *** CD-ROM | disk | FTP | other *** search
- unit MyDocsU;
-
- {$ifdef Ver90} { Delphi 2.0x }
- {$define DelphiLessThan3}
- {$endif}
- {$ifdef Ver93} { C++ Builder 1.0x }
- {$define DelphiLessThan3}
- {$endif}
-
- interface
-
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- StdCtrls;
-
- type
- TForm1 = class(TForm)
- Label1: TLabel;
- procedure FormCreate(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- {$R *.DFM}
-
- uses
- {$ifdef DelphiLessThan3}
- OLE2,
- {$else}
- ActiveX,
- {$endif}
- ShellAPI, ShlObj;
-
- function GetMyDocuments: String;
- var
- PIDL: PItemIDList;
- MyDocsC: array[0..MAX_PATH] of Char;
- Malloc: IMalloc;
- begin
- SHGetMalloc(Malloc);
- if (SHGetSpecialFolderLocation(
- Application.Handle, CSIDL_PERSONAL, PIDL) = NOERROR) and
- SHGetPathFromIDList(PIDL, MyDocsC) then
- begin
- Result := MyDocsC;
- Malloc.Free(PIDL)
- end
- else
- raise EInvalidOp.Create(
- 'Cannot find personal documents folder')
- end;
-
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- Label1.Caption :=
- 'The personal folder is located at: ' +
- GetMyDocuments
- end;
-
- end.
-